//
//  SexViewController.m
//  hello mui
//
//  Created by zhangtao on 15/9/14.
//  Copyright (c) 2015年 zt.td. All rights reserved.
//

#import "SexViewController.h"

#define MALE @"男";
#define FEMALE @"女";

@interface SexViewController ()
@property (weak, nonatomic) IBOutlet UIView *a;
@property (weak, nonatomic) IBOutlet UIView *b;

@property(nonatomic,strong)NSString *sexValue;
@end

@implementation SexViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _sexValue = MALE
    self.title = @"性别";
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
//    self.view.backgroundColor = [UIColor colorWithRed:240/155.f green:240/155.f blue:240/155.f alpha:1];
//    [self initSytle];
    if ([self.infoVC.sex.text isEqualToString:@"男"]) {
        self.maleIV.image = [UIImage imageNamed:@"item_selected.png"];
    }else if ([self.infoVC.sex.text isEqualToString:@"女"]){
        self.feMaleIV.image = [UIImage imageNamed:@"item_selected.png"];
    }

    
    
    _a.layer.borderColor = _b.layer.borderColor = [[UIColor colorWithRed:230/255.f green:230/255.f blue:230/255.f alpha:1]CGColor];
    _a.layer.borderWidth = _b.layer.borderWidth = 1;
    
}


- (IBAction)selectSex:(UIButton *)sender {
    _feMaleIV.image = _maleIV.image = nil;//[UIImage imageNamed:@"item_normal.png"];
    UIImage *image = [UIImage imageNamed:@"item_selected.png"];
    if (sender.tag == 0) {
        _maleIV.image = image;
        _sexValue = MALE

    }else{
        _feMaleIV.image = image;
        _sexValue = FEMALE
    }
    _infoVC.sex.text = _sexValue;
    NSUSER_DEF_NORSET(_infoVC.sex.text, @"SEX");
    
    NSString *sex;
    if ([_sexValue isEqualToString:@"男"]) {
        sex = @"0";
    }else{
        sex = @"1";
    }
    
    [self submit:sex];
}

-(void)submit:(NSString *)sex{
    NSString *path = @"login/updateUser";
    
    NSString *userId = [NSString stringWithFormat:@"%@",NSUSER_DEF(@"USERID")];
    
    NSDictionary *dic = @{@"userId":userId,@"gener":sex};
    NSDictionary *dics = @{@"userId":userId,@"gener":sex,@"bd_sig":[ToolObjc md5Str:dic]};
    [[HttpConnctionManager sharedInstance]requestParam:dics andUrl:path andSuccessedBlock:^(NSDictionary *succeedResult) {
        NSLog(@"~~~%@",succeedResult);
        //        NSLog(@"~~~~~~%@,%@",[NSString stringWithFormat:@"%@",[succeedResult stringWithFilted:@"resCode"]],[succeedResult stringWithFilted:@"resMessage"]);
        //        NSLog(@"%@",succeedResult);
        [self.navigationController popViewControllerAnimated:YES];
    } andFailedBlock:^(AFHTTPRequestOperation *response, NSError *error) {
        NSLog(@"error::%@",error);
    }];
    

    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//-(UIButton *)button *

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
